﻿@using OASystem.Model;
@{ 
    Maillist maillist = ViewBag.mail as Maillist;
}
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>通讯录</title>
    <link href="~/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="~/css/tail.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="~/js/jquery.js"></script>
    <script>
        function change() {
            var height01 = $(window).height();
            $(".top").css('height', height01 - 35+"px");
        }
    </script>
</head>

<body style="border-radius: 8px" onload="change()">
<!--<div class="title"><h2>通知详情</h2></div>-->
<form id="form_demo" >
<div class="top">
    <div>
        <div class="top_out">
            <table class="table" >
                <tbody>

                    <tr>
                        <input type="text" id="Id" name="name" minlength="2" required value="@maillist.Id" style="display:none">
                        <td>姓名：<i class="i_start"></i> </td>
                        <td style="text-align: left"><input type="text" name="name" minlength="2" value="@maillist.Name" required id="Name"></td>
                        <td>所属职位：</td>
                        <td style="text-align: left">
                            <select id="PosId">
                                @if (ViewBag.Position != null)
                                {
                                    foreach (Position item in ViewBag.Position)
                                    {
                                        <option value="@item.PosId">@item.PosName</option>
                                    }
                                }

                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>所属部门：</td>
                        <td style="text-align: left">
                            <select id="DepartId">
                                @if (ViewBag.List != null)
                                {
                                    foreach (Departinfo item in ViewBag.List)
                                    {
                                        <option value="@item.DepartId">@item.DepartName</option>
                                    }
                                }
                            </select>
                        </td>
                        <td>邮箱地址：</td>
                        <td colspan="5" style="text-align: left"><input type="email" id="Email" value="@maillist.Pinyin"></td>
                    </tr>
                <tr>
                    <td>移动电话：</td>
                    <td  style="text-align: left"><input type="text" id="Tel" value="@maillist.Tel"></td>
                    <td>邮箱地址：</td>
                    <td colspan = "5" style="text-align: left"><input type="email" id="Email" value="@maillist.Email"></td>
                </tr>
            </table>
        </div>
    </div>
    <div class="bot_btn">
        <input type="button" id="btn" value="保存" class="btn">
        <button class="btn btn1"><a href="mailList.html" target="right">返回</a></button>
    </div>
</div>
</form>
</body>
<script type="text/javascript" src="~/js/jquery.js"></script>
<script src="~/js/layer.js"></script>
<script>

    $(function () {
        $("#btn").click(function(){
            var data = {};
            data.Id = $("#Id").val();
            data.Name = $("#Name").val();
            data.DepartId = $("#DepartId").val();
            data.PosId = $("#PosId").val();
            data.Tel = $("#Tel").val();
            data.Email = $("#Email").val();
            $.ajax({
                type: "post",
                url: "/MailList/MailUpdate",
                data: data,
                success: function (responseResult) {
                    if (responseResult.success) {
                        layer.msg('编辑成功!', { icon: 6, time: 1000 });
                        window.location.href = "/Home/MailList";
                    } else {
                        layer.msg('编辑失败!', { icon: 6, time: 1000 });
                    }
                }
            })
        })
    })
   /* var PROJECTID, TASKTYPE, TASKPHASE,  PERSONID
    !function () {
        laydate.skin('danlan');//切换皮肤，请查看skins下面皮肤库
        laydate({ elem: '#demo' });//绑定元素
        laydate({ elem: '#demo1' });
        laydate({ elem: '#demo2' });//绑定元素
    }();
    function init() {
        if (parent.getCurrentID() != "") {
            $.ajax({
                url: '../TaskRecord/SearchTaskById?taskId=' + parent.getCurrentID(),
                type: 'POST',
                dataType: 'json',
                success: function (result) {
                    var data = result.data;
                    if (data) {
                        PROJECTID = data.PROJECTID
                        PERSONID =data.PERSONID
                        TASKPHASE = data.TASKPHASE;
                        TASKTYPE = data.TASKTYPE;
                        $("#name").val(data.PROJECTNAME);
                        $("#work").val(data.TASKPHASENAME);
                        $("#part").val(data.STATE);

//                        $("#demo").val(getFormatTime(data.STARTTIME.substring(6,19)));
//                        $("#demo01").val(getFormatTime(data.STARTTIME.substring(6,19)));
                        $("#tele01").val(data.NOTE);
                        $("#tele02").val(data.NOTE);
                        $("#email01").val(data.NOTE);
                        $("#editor").val(data.NOTE);

                        getWork();
                        getPart();

                    }*/
                   /* else {
                        alert("获取失败！");
                    }
                },
                error: function (err) {
                }
            })


        }
        else {
            getWork();
            getPart();
        }
        function Save() {
            $.ajax({
                type: "POST",
                url: "../TaskRecord/UpdateTask",
                data: {
                    TASKID: parent.getCurrentID(),
                    PROJECTID: PROJECTID,
                    STATE: $("#name").val(),
                    TASKPHASE: $("#work").val(),
                    TASKPHASE: $("#part").val(),
                    STARTTIME: $("#tele02").val(),
                    STARTTIME: $("#tele01").val(),
                    TASKTYPE: $("#email01").val(),

                    NOTE: $("#editor").val(),



                },
                dataType: "~/json",
                success: function (result) {
                    if (result.data) {
                        alert("保存成功！！！");
                        parent.getNoticeTableData();
                        TaskCancel();
                    } else {
                        alert("保存失败！！！")
                    }
                }
            })

        }
        function TaskCancel() {
            var index = parent.layer.getFrameIndex(window.name)
            parent.layer.close(index);
        }
        //初始化部门下拉菜单
    function getPart() {
        $.ajax({
            url: '../Common/GetPhaseList',
            type: 'GET',
            dataType: 'json',
            success: function (data) {
                var PHASEValue = data.data;
                if (PHASEValue.length > 0) {
                    $("#part").html("");
                    for (var i = 0; i < PHASEValue.length; i++) {
                        if (TASKPHASE == PHASEValue[i].ID) {
                            var html = "<Option value = '" + PHASEValue[i].ID + "'  selected = 'true'>" + PHASEValue[i].NAME + "</Option>";
                        } else {
                            var html = "<Option value = '" + PHASEValue[i].ID + "'>" + PHASEValue[i].NAME + "</Option>";
                        };
                        $("#part").append(html);
                    }
                }


            },
            error: function (err) {
            }

        })
    }
        //初始化职位下拉菜单
        function getWork() {
            $.ajax({
                url: '../Common/GetPhaseList',
                type: 'GET',
                dataType: 'json',
                success: function (data) {
                    var PHASEValue = data.data;
                    if (PHASEValue.length > 0) {
                        $("#work").html("");
                        for (var i = 0; i < PHASEValue.length; i++) {
                            if (TASKPHASE == PHASEValue[i].ID) {
                                var html = "<Option value = '" + PHASEValue[i].ID + "'  selected = 'true'>" + PHASEValue[i].NAME + "</Option>";
                            } else {
                                var html = "<Option value = '" + PHASEValue[i].ID + "'>" + PHASEValue[i].NAME + "</Option>";
                            };
                            $("#work").append(html);
                        }
                    }


                },
                error: function (err) {
                }

            })
        }*/

        //时间格式化函数
        function getFormatTime(time) {
            var time = new Date(parseInt(time));
            var y = time.getFullYear();
            var m = time.getMonth() + 1;
            var d = time.getDate();
            var h = time.getHours();
            var mm = time.getMinutes();
            var s = time.getSeconds();
            return y + '-' + add0(m) + '-' + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s);
        }
        function add0(m) { return m < 10 ? '0' + m : m }
</script>
</html>
